<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
<head><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    <title>6.46. Mktemp-1.5</title>
    <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type="text/css" media="print" />
<script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
</head>
  <body id="lfs" class="6.2">
    <div class="navheader">
      <div class="headertitles">
        <h4>Linux From Scratch - 版本 6.2</h4>
        <h3>第六章 安装系统基础软件</h3>
      </div>
      <ul class="headerlinks">
        <li class="prev">
          <a accesskey="p" href="man-db.html" title="Man-DB-2.4.3">后退</a>
          <p>Man-DB-2.4.3</p>
        </li>
        <li class="next">
          <a accesskey="n" href="module-init-tools.html" title="Module-Init-Tools-3.2.2">前进</a>
          <p>Module-Init-Tools-3.2.2</p>
        </li>
        <li class="up"><a accesskey="u" href="chapter06.html" title="第六章 安装系统基础软件">上一级</a></li>
        <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a></li>
      </ul>
    </div>
    <div class="wrap">
      <div class="titlepage">
        <h1 class="sect1">6.46. Mktemp-1.5</h1>
      </div>
      <div class="package">
        <p>Mktemp 软件包包含用于在 shell 脚本中创建安全临时文件的程序。</p>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong><span class="segtitle">预计编译时间：</span></strong> <span class="seg">少于 0.1 SBU</span>
            </div>
            <div class="seg">
              <strong><span class="segtitle">所需磁盘空间：</span></strong> <span class="seg">0.4 MB</span>
            </div>
          </div>
        </div>
      </div>
      <div class="installation">
        <div class="titlepage">
          <h2 class="sect2">6.46.1. 安装 Mktemp</h2>
        </div>
        <p>许多脚本目前仍然使用被反对使用的类似于 <span><strong class="command">mktemp</strong></span> 的 <span><strong class="command">tempfile</strong></span> 程序，我们现在要给 Mktemp 打一个补丁，以使它包含 <span><strong class="command">tempfile</strong></span> 包装：</p>
        <pre class="userinput"><kbd class="command">patch -Np1 -i ../mktemp-1.5-add_tempfile-3.patch</kbd></pre>
        <p>为编译 Mktemp 做准备：</p>
        <pre class="userinput"><kbd class="command">./configure --prefix=/usr --with-libc</kbd></pre>
        <div class="variablelist">
          <p class="title">
            <b>配置选项的含义：</b></p>
          <dl>
            <dt>
              <span class="term"><em class="parameter"><tt>--with-libc</tt></em></span>
            </dt>
            <dd>
              <p>这个使得 <span><strong class="command">mktemp</strong></span> 程序从系统的 C 库中使用 <span class="emphasis"><em>mkstemp</em></span> 和 <span class="emphasis"><em>mkdtemp</em></span> 的功能。</p>
            </dd>
          </dl>
        </div>
        <p>编译软件包：</p>
        <pre class="userinput"><kbd class="command">make</kbd></pre>
        <p>这个软件包没有附带测试程序。</p>
        <p>安装软件包：</p>
        <pre class="userinput"><kbd class="command">make install
make install-tempfile</kbd></pre>
      </div>
      <div class="content">
        <div class="titlepage">
          <a id="contents-mktemp" name="contents-mktemp"></a>
          <h2 class="sect2">6.46.2. Mktemp 的内容</h2>
        </div>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong><span class="segtitle">安装的程序：</span></strong> <span class="seg">mktemp, tempfile</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3><a id="id3692478" name="id3692478"></a>简要描述</h3>
          <table border="0">
            <col align="left" valign="top" />
            <tbody>
              <tr>
                <td><a id="mktemp" name="mktemp"></a><span class="term"><span><strong class="command">mktemp</strong></span></span></td>
                <td><p>使用安全性较强的方式创建临时文件，用于脚本中。</p></td>
              </tr>
              <tr>
                <td><a id="tempfile" name="tempfile"></a><span class="term"><span><strong class="command">tempfile</strong></span></span></td>
                <td><p>使用比 <span><strong class="command">mktemp</strong></span> 安全性较弱的方式创建临时文件，但是能够满足向后的兼容性。</p></td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="man-db.html" title="Man-DB-2.4.3">后退</a>
          <p>Man-DB-2.4.3</p>
        </li>
        <li class="next">
          <a accesskey="n" href="module-init-tools.html" title="Module-Init-Tools-3.2.2">前进</a>
          <p>Module-Init-Tools-3.2.2</p>
        </li>
        <li class="up"><a accesskey="u" href="chapter06.html" title="第六章 安装系统基础软件">上一级</a></li>
        <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a>.
        </li>
      </ul>
    </div>
</body></html>
